package com.common.dto;


/**
 * @ClassName: LiveMatch
 * @Description: 盘中信息对象
 * @author lilei
 * @date 2012-10-11 上午10:30:50
 * 
 */

public class LiveMatch {

	private String leagueName; // 联赛名称
	private String leagueSelfID;	//第三方联赛id
	private String matchName; // 赛事名称
	private String matchSelfID;//第三方赛事id
	private String showTime = "0"; // 显示时间  足球 篮球 篮球为倒记时间
	private String systemTime; // 系统时间
	private int status = 1; //足球：-1未开赛 0中场,1上半场,2下半场, 4 开始上半场加时赛 ,5 停止上半场加时赛,6 开始下班场加时赛,7 结束下半场加时赛,8 开始点球大战,9 停止点球大战
							//篮球 -1未开赛 1为第一节 2为第二节 3为第三节 4为第4节 5为加时    0中场
	private int closeStatus = 0; // 足球 是否收盘 0未收盘,1全部盘口收盘,2上半场盘口收盘,3赛事消失收盘
	private int homeYC = 0; // 主队红牌数  //足球才有
	private int awayYC = 0; // 客队红牌数 //足球才有
	
	private int homeGoal = 0; // 主队进球数  网球代表盘数
	private int awayGoal = 0; // 客队进球数  网球代表盘数
	
	private int hboutCoal =0; //局分 网球专用
	private int aboutCoal =0; //局分 网球专用
	
	private String hscoreCoal;	//得分 网球专用
	private String ascoreCoal;  //得分 网球专用
	
	private String lastGoal;	//最后进球
	private String nowServer;   //发球方   1 为主队 2为客队 网球用到

	/**
	 * 克隆对象
	 */
	public LiveMatch clone() {

		LiveMatch liveMatch = null;

		try {
			liveMatch = (LiveMatch) super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}

		return liveMatch;
	}

	/**
	 * 判断当前赛事的比分，红牌是否发生改变
	 * 
	 * @param comLiveMatch
	 * @return
	 */
	public boolean isChangeYCorGoal(LiveMatch comLiveMatch) {
		if (comLiveMatch == null) {
			return false;
		}
		if (this.homeYC > comLiveMatch.getHomeYC() || this.awayYC > comLiveMatch.getAwayYC() || this.homeGoal > comLiveMatch.getHomeGoal()
				|| this.awayGoal > comLiveMatch.getAwayGoal()) {
			return true;
		}
		return false;
	}

	/**
	 * 比较对象是否发生变化 0未发生变化,-1发生变化
	 */
	public int compareTo(LiveMatch newLiveMatch) {
		int ret = -1;

		if (this == newLiveMatch) {
			ret = 0;
			return ret;
		}

		if (newLiveMatch == null) {
			return ret;
		}

		// 比较联赛名称
		if (!this.getLeagueName().equals(newLiveMatch.getLeagueName())) {
			return ret;
		}

		// 比较赛事名称
		if(!this.getMatchName().equals(newLiveMatch.getMatchName())){
			return ret;
		}
		// 比较小节信息
		if (this.getStatus() != newLiveMatch.getStatus()) {
			if ((this.getStatus() == -1) || (this.getStatus() == 1 && newLiveMatch.getStatus() == 0)
					|| (this.getStatus() == 0 && newLiveMatch.getStatus() == 2) 
					|| (this.getStatus() == 2 && newLiveMatch.getStatus() > 2) 
					|| (newLiveMatch.getStatus() > 2 && newLiveMatch.getStatus() > this.getStatus())
					) {
				return ret;
			}
		}

		// 比较收盘信息
		if (this.getCloseStatus() != newLiveMatch.getCloseStatus()) {
			// if (this.getCloseStatus() == 0) {
			// return ret;
			// }
			return ret;
		}

		// 比较主队进球数
		if (this.getHomeGoal() != newLiveMatch.getHomeGoal()) {
			return ret;
		}

		// 比较主队红牌数
		if (this.getHomeYC() != newLiveMatch.getHomeYC()) {
			return ret;
		}

		// 比较客队进球数
		if (this.getAwayGoal() != newLiveMatch.getAwayGoal()) {
			return ret;
		}

		// 比较客队红牌数
		if (this.getAwayYC() != newLiveMatch.getAwayYC()) {
			return ret;
		}

		ret = 0;
		return ret;
	}
	
	/**
	* @Title: compareToCloseStatus
	* @Description: 比较除收盘状态外变化 0未发生变化,-1发生变化(W表示without)
	* @author lilei 
	* @param newLiveMatch
	* @return
	* @return int        返回类型
	* @throws
	*/
	public int compareToWCloseStatus(LiveMatch newLiveMatch) {
		int ret = -1;

		if (this == newLiveMatch) {
			ret = 0;
			return ret;
		}

		if (newLiveMatch == null) {
			return ret;
		}

		// 比较联赛名称
		if (!this.getLeagueName().equals(newLiveMatch.getLeagueName())) {
			return ret;
		}

		// 比较赛事名称
		if(!this.getMatchName().equals(newLiveMatch.getMatchName())){
			return ret;
		}
		
		// 比较小节信息
		if (this.getStatus() != newLiveMatch.getStatus()) {
			if ((this.getStatus() == -1) || (this.getStatus() == 1 && newLiveMatch.getStatus() == 0)
					|| (this.getStatus() == 0 && newLiveMatch.getStatus() == 2)) {
				return ret;
			}
		}

	

		// 比较主队进球数
		if (this.getHomeGoal() != newLiveMatch.getHomeGoal()) {
			return ret;
		}

		// 比较主队红牌数
		if (this.getHomeYC() != newLiveMatch.getHomeYC()) {
			return ret;
		}

		// 比较客队进球数
		if (this.getAwayGoal() != newLiveMatch.getAwayGoal()) {
			return ret;
		}

		// 比较客队红牌数
		if (this.getAwayYC() != newLiveMatch.getAwayYC()) {
			return ret;
		}

		ret = 0;
		return ret;
		
	}
	
	/**
	* @Title: compareToStatus
	* @Description: 比较状态变化
	* @author lilei 
	* @param comLiveMatch
	* @return
	* @return boolean        返回类型
	* @throws
	*/
	public boolean compareToStatus(LiveMatch LiveMatch) {
		if (LiveMatch == null) {
			return false;
		}
		// 比较小节信息
		if (this.getStatus() != LiveMatch.getStatus()) {
			return true;
		}
		// 比较收盘信息
		if (this.getCloseStatus() != LiveMatch.getCloseStatus()) {
			return true;
		}
		return false;
	}
	
	/**
	* @Title: compareToYCorGoal
	* @Description: 比较红牌比分变化
	* @author lilei 
	* @param comLiveMatch
	* @return
	* @return boolean        返回类型
	* @throws
	*/
	public boolean compareToYCorGoal(LiveMatch comLiveMatch) {
		if (comLiveMatch == null) {
			return false;
		}
		if (this.homeYC != comLiveMatch.getHomeYC() || this.awayYC != comLiveMatch.getAwayYC() || this.homeGoal != comLiveMatch.getHomeGoal()
				|| this.awayGoal != comLiveMatch.getAwayGoal()) {
			return true;
		}
		return false;
	}
	/**
	* @Title: compareToWStatus
	* @Description: 比较除安全球状态外变化 0未发生变化,-1发生变化(W表示without)
	* @author lilei 
	* @param newLiveMatch
	* @return
	* @return int        返回类型
	* @throws
	*/
	public int compareToWSafeStatus (LiveMatch newLiveMatch) {
		int ret = -1;

		if (this == newLiveMatch) {
			ret = 0;
			return ret;
		}

		if (newLiveMatch == null) {
			return ret;
		}

		// 比较联赛名称
		if (!this.getLeagueName().equals(newLiveMatch.getLeagueName())) {
			return ret;
		}
		// 比较赛事名称
		if(!this.getMatchName().equals(newLiveMatch.getMatchName())){
			return ret;
		}

		// 比较小节信息
		if (this.getStatus() != newLiveMatch.getStatus()) {
			if ((this.getStatus() == -1) || (this.getStatus() == 1 && newLiveMatch.getStatus() == 0)
					|| (this.getStatus() == 0 && newLiveMatch.getStatus() == 2)) {
				return ret;
			}
		}

		// 比较收盘信息
		if (this.getCloseStatus() != newLiveMatch.getCloseStatus()) {
			// if (this.getCloseStatus() == 0) {
			// return ret;
			// }
			return ret;
		}

		// 比较主队进球数
		if (this.getHomeGoal() != newLiveMatch.getHomeGoal()) {
			return ret;
		}

		// 比较主队红牌数
		if (this.getHomeYC() != newLiveMatch.getHomeYC()) {
			return ret;
		}

		// 比较客队进球数
		if (this.getAwayGoal() != newLiveMatch.getAwayGoal()) {
			return ret;
		}

		// 比较客队红牌数
		if (this.getAwayYC() != newLiveMatch.getAwayYC()) {
			return ret;
		}

		ret = 0;
		return ret;
	}
	/**
	 * 比较对象是否发生变化 0表示新数据,-1表示老数据
	 */
	public int old(LiveMatch newLiveMatch) {
		int ret = -1;

		if (this == newLiveMatch) {
			ret = 0;
			return ret;
		}

		if (newLiveMatch == null) {
			return ret;
		}

		// 比较小节信息
		if (this.getStatus() != newLiveMatch.getStatus()) {
			if ((this.getStatus() == -1) || (this.getStatus() == 0 && newLiveMatch.getStatus() == 1)
					|| (this.getStatus() == 2 && (newLiveMatch.getStatus() == 0 || newLiveMatch.getStatus() == 1))) {
				return ret;
			}
		}

		// 比较主队进球数
		if (this.getHomeGoal() != newLiveMatch.getHomeGoal()) {
			return ret;
		}

		// 比较主队红牌数
		if (this.getHomeYC() != newLiveMatch.getHomeYC()) {
			return ret;
		}

		// 比较客队进球数
		if (this.getAwayGoal() != newLiveMatch.getAwayGoal()) {
			return ret;
		}

		// 比较客队红牌数
		if (this.getAwayYC() != newLiveMatch.getAwayYC()) {
			return ret;
		}

		// 比较收盘信息
		if (this.getCloseStatus() != newLiveMatch.getCloseStatus()) {
			if (newLiveMatch.getCloseStatus() == 2) {
				ret = 0;
				return ret;
			}
			return ret;
		}

		ret = 0;

		return ret;
	}

	public String getLeagueName() {
		return leagueName;
	}

	public void setLeagueName(String leagueName) {
		this.leagueName = leagueName;
	}


	public String getShowTime() {
		return showTime;
	}

	public void setShowTime(String showTime) {
		this.showTime = showTime;
	}

	public int getHomeYC() {
		return homeYC;
	}

	public void setHomeYC(int homeYC) {
		this.homeYC = homeYC;
	}

	public int getAwayYC() {
		return awayYC;
	}

	public void setAwayYC(int awayYC) {
		this.awayYC = awayYC;
	}

	public int getHomeGoal() {
		return homeGoal;
	}

	public void setHomeGoal(int homeGoal) {
		this.homeGoal = homeGoal;
	}

	public int getAwayGoal() {
		return awayGoal;
	}

	public void setAwayGoal(int awayGoal) {
		this.awayGoal = awayGoal;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getCloseStatus() {
		return closeStatus;
	}

	public void setCloseStatus(int closeStatus) {
		this.closeStatus = closeStatus;
	}

	public String getSystemTime() {
		return systemTime;
	}

	public void setSystemTime(String systemTime) {
		this.systemTime = systemTime;
	}

	public String getLeagueSelfID() {
		return leagueSelfID;
	}

	public void setLeagueSelfID(String leagueSelfID) {
		this.leagueSelfID = leagueSelfID;
	}


	public int getHboutCoal() {
		return hboutCoal;
	}

	public void setHboutCoal(int hboutCoal) {
		this.hboutCoal = hboutCoal;
	}

	public int getAboutCoal() {
		return aboutCoal;
	}

	public void setAboutCoal(int aboutCoal) {
		this.aboutCoal = aboutCoal;
	}


	public String getHscoreCoal() {
		return hscoreCoal;
	}

	public void setHscoreCoal(String hscoreCoal) {
		this.hscoreCoal = hscoreCoal;
	}

	public String getAscoreCoal() {
		return ascoreCoal;
	}

	public void setAscoreCoal(String ascoreCoal) {
		this.ascoreCoal = ascoreCoal;
	}

	public String getMatchName() {
		return matchName;
	}

	public void setMatchName(String matchName) {
		this.matchName = matchName;
	}

	public String getMatchSelfID() {
		return matchSelfID;
	}

	public void setMatchSelfID(String matchSelfID) {
		this.matchSelfID = matchSelfID;
	}

	public String getLastGoal() {
		return lastGoal;
	}

	public void setLastGoal(String lastGoal) {
		this.lastGoal = lastGoal;
	}

	public String getNowServer() {
		return nowServer;
	}

	public void setNowServer(String nowServer) {
		this.nowServer = nowServer;
	}



}
